#include<bits/stdc++.h>
using namespace std;
int n,l,r;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&l,&r);
	if(r-l>=n) printf("%d\n",n-1);
	else{
		if(r%n>l%n) printf("%d\n",r%n);
		else printf("%d\n",n-1);
	}
	return 0;
}
